//
// Created by tcj on 2022/4/1.
//

#include "sylar/tcp_server.h"
#include "sylar/iomanager.h"

sylar::Logger::ptr g_logger = SYLAR_LOG_ROOT();

void run(){
    auto addr = sylar::Adress::LookupAny("0.0.0.0:80");
    auto addr2 = sylar::UnixAdress::ptr(new sylar::UnixAdress("/tmp/unix_addr"));
//    SYLAR_LOG_INFO(g_logger)<<*addr<<" - "<<addr2;
    std::vector<sylar::Adress::ptr> addrs;
    addrs.push_back(addr);
    addrs.push_back(addr2);

    sylar::TcpServer::ptr tcp_server(new sylar::TcpServer);
    std::vector<sylar::Adress::ptr> fails;
    while(!tcp_server->bind(addrs,fails)){
        sleep(2);
    }
    tcp_server->start();
}

int main(){
    sylar::IOManager iom(2);
    iom.schedule(run);
    return 0;
}